<script setup>
import { computed } from 'vue'
import _ from 'lodash'

const props = defineProps({
    name: String,
    size: {
        type: [String, Number],
        default: 'inherit'
    },
    type: String,
})
const iconHref = computed(() => '#' + props.name)
const iconSize = computed(() => {
    return props.size + ((_.isNumber(props.size) || /^\d+$/.test(props.size)) ? 'px' : '')
})
</script>

<template>
    <svg class="svg-icon" :type="type" aria-hidden="true">
        <use :xlink:href="iconHref"/>
    </svg>
</template>

<style scoped>
.svg-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    font-size: v-bind(iconSize);
    fill: currentColor;
    overflow: hidden;
}

</style>